home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include <math.h>
- #include <gl.h>
- #include <device.h>
- #include <sys/time.h>
- #include "exbookglo.h"
- #include "exglobals.h"
-
- short highlightcolor = 13;
- extern Matrix *dummy;
-
- float flatpage[4][2] = {
- {0.0, 0.0},
- {PGWIDTH, 0.0},
- {PGWIDTH, PGHEIGHT},
- {0.0, PGHEIGHT}
- };
-
-
- float texbox[4][3] = { {0.2, 0.33, 0.0},
- {1.8, 0.33, 0.0},
- {1.8, 2.0, 0.0},
- {0.2, 2.0, 0.0} };
-
- float texnorm[3] = {0.0, 0.0, 1.0};
-
- float texpnts[4][2] = { {0.0, 0.0},
- {1.0, 0.0},
- {1.0, 1.0},
- {0.0, 1.0} };
-
- /*
- float tex_props[] = {TX_MINFILTER,TX_MIPMAP_BILINEAR,
- TX_MAGFILTER,TX_BILINEAR,TX_NULL};
- float env_props[] = {TV_NULL};
-
- */
-
-
- /* routines in this file are:
-
- void drawscene (frame)
- void pickdrawscene (frame)
- */
-
- void close_book()
- {
- resetshelfcolors();
- unhighlighticon();
- OPENBOOK = FALSE;
- currentbook = -1;
- curgroup = NULL;
- leftpage = NULL;
- middlepage = NULL;
- rightpage = NULL;
- dobookview();
- /*
- setcursor(0,0,0);
- */
-
- }
- /************************************************************
- *
- * Draw the outline of a flat page. This is used to drag
- * the page when the groups are re-arranged in that window.
- *
- ************************************************************/
- void overdrawflatpage(int i)
- {
- color(0);
- clear();
- color(3);
- bgnline();
- v2f(flatpage[0]);
- v2f(flatpage[1]);
- v2f(flatpage[2]);
- v2f(flatpage[3]);
- v2f(flatpage[0]);
- endline();
- }
-
- /************************************************************
- *
- * Draw the flat page. This is used to draw a page in the
- * index window and in the re-arrange group window.
- *
- ************************************************************/
- void drawflatpage(int i)
- {
- loadname(i);
- c3s(morecolors[117]);
- bgnpolygon();
- v2f(flatpage[0]);
- v2f(flatpage[1]);
- v2f(flatpage[2]);
- v2f(flatpage[3]);
- endpolygon();
- c3s(morecolors[Black]);
- bgnline();
- v2f(flatpage[0]);
- v2f(flatpage[1]);
- v2f(flatpage[2]);
- v2f(flatpage[3]);
- v2f(flatpage[0]);
- endline();
- }
-
- void drawicon_img(Boolean highlight_flag, struct icntmpltstruct *ic)
- {
- float vect[3];
- int i;
-
- c3s(morecolors[White]);
- /*ERROR I broke texture mapping when I deleted the lighting stuff from bookinit.c */
- lmbind(MATERIAL,1);
- texbind(TX_TEXTURE_0, ic->tex_id);
- tevbind(TV_ENV0, 1);
- bgnpolygon();
- n3f(texnorm); t2f(texpnts[3]); v3f(texbox[3]);
- n3f(texnorm); t2f(texpnts[2]); v3f(texbox[2]);
- n3f(texnorm); t2f(texpnts[1]); v3f(texbox[1]);
- endpolygon();
- bgnpolygon();
- n3f(texnorm); t2f(texpnts[3]); v3f(texbox[3]);
- n3f(texnorm); t2f(texpnts[1]); v3f(texbox[1]);
- n3f(texnorm); t2f(texpnts[0]); v3f(texbox[0]);
- endpolygon();
-
- lmbind(MATERIAL,0);
- texbind(TX_TEXTURE_0, 0);
- tevbind(TV_ENV0, 0);
- }
-
- void print_poly(struct icntmpltstruct *ic)
- {
- int i, j, k, limit;
- struct polylist *curpoly;
-
- curpoly = ic->poly;
- limit = ic->numpoly;
- for (j = 0; j < limit; j++)
- {
- k = 0;
- if (curpoly->poly >= 0)
- {
- printf(" p\n ");
- while (curpoly != NULL && curpoly->ndcs[k] >= 0)
- {
- printf(" %d %f %f %f \n", curpoly->ndcs[k], icon_verts[curpoly->ndcs[k]+0],
- icon_verts[curpoly->ndcs[k]+1],
- icon_verts[curpoly->ndcs[k]+2]);
- k++;
- }
- }
- k = 0;
- if (curpoly->line >= 0)
- {
- printf(" l\n ");
- while (curpoly != NULL && curpoly->ndcs[k] >= 0)
- {
- printf(" %d %f %f %f \n", curpoly->ndcs[k], icon_verts[curpoly->ndcs[k]+0],
- icon_verts[curpoly->ndcs[k]+1],
- icon_verts[curpoly->ndcs[k]+2]);
- k++;
- }
- }
- }
- }
-
- /************************************************************
- *
- * Draw a WorkSpace icon. Assume that the transformation
- * matrices are already set up.
- *
- ************************************************************/
- void drawicon_geom(Boolean selection_flag, struct icntmpltstruct *ic)
- {
- int i, j, k, limit;
- struct polylist *curpoly;
-
- curpoly = ic->poly;
- limit = ic->numpoly;
- for (j = 0; j < limit; j++)
- {
- k = 0;
- if (curpoly->poly >= 0)
- {
- c3s(morecolors[curpoly->poly]);
- bgnpolygon();
- while (curpoly != NULL && curpoly->ndcs[k] >= 0)
- {
- v2f((float*)icon_verts[curpoly->ndcs[k]]);
- k++;
- }
- endpolygon();
- }
- k = 0;
- if (curpoly->line >= 0)
- {
- c3s(morecolors[curpoly->line]);
- bgnline();
- while (curpoly != NULL && curpoly->ndcs[k] >= 0)
- {
- v2f((float*)icon_verts[curpoly->ndcs[k]]);
- k++;
- }
- endline();
- }
- curpoly++;
- }
- }
-
- /************************************************************
- *
- * Draw all the icons on a flat page. Does the translates.
- *
- ************************************************************/
- void drawflaticons(thispage)
- struct pagestruct *thispage;
- {
- struct iconstruct *tmpiconptr;
-
- tmpiconptr = thispage->fronticons;
- while (tmpiconptr != NULL)
- {
- pushmatrix();
- translate(tmpiconptr->xposition_ndx*2.0, tmpiconptr->yposition_ndx*2.0, 0.0);
- drawicon_geom(0,tmpiconptr->iconptr);
- popmatrix();
- tmpiconptr = tmpiconptr->nexticon;
- }
- }
-
- /************************************************************
- *
- * Streamlined drawscene so picking will be faster.
- *
- ************************************************************/
- void pickdrawscene(int frame)
- {
- if (OPENBOOK)
- {
- pushmatrix();
- rot(-25.0, 'x');
- translate(0.0, 1.0, 0.0);
- pickdrawopenframe(frame);
- popmatrix();
- }
- else
- pickdrawshelves();
- }
-
- /************************************************************
- *
- * draws the scene where the current page can be anywhere
- * in a turn.
- *
- ************************************************************/
- void drawscene(int frame)
- {
- dobookview();
- c3s(morecolors[Black]);
- clear();
- if (OPENBOOK)
- {
- setcovercolor(curgroup);
- pushmatrix();
- rot(-25.0, 'x');
- translate(0.0, 1.0, 0.0);
- drawopenframe(frame);
- popmatrix();
- }
- else
- drawbookcase();
- swapbuffers();
- }
-